<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    {% block one %}
    {% endblock %}

    {% block two %}
    {% endblock %}

    <form>
        <input type="text" id="username" placeholder="请输入用户名">
        <input type="password" id="password" placeholder="请输入密码">
        <button type="button" id="send">发送</button>
        {% csrf_token %}
    </form>
{#    <a href={% url "info" s.name s.age s.sex %}>#}
{#        学生 {{ s.name }} 的个人信息#}
{#    </a>#}

    <script type="text/javascript" charset="UTF-8" src="/static/js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" charset="UTF-8">
        $(function () {
            $.get('{% url "info" s.name s.age s.sex %}', function (stu) {
                console.log(stu);
            });
            $.get('/media/one.jpg', function (pic) {
                console.log(pic);
            })
        });
        $('#send').click(function () {
            $.ajax({
                url: '/api_example/',
                type: 'POST',
                data: {
                    username: $('#username').val(),
                    password: $("#password").val(),
                },
                dataType: "json",
                success: function (data) {
                    if (data.status === "OK") {
                        alert('登录成功');
                    }
                },
                error: function (jpXHR) {
                    alert("Status Code: " + jpXHR.status);
                }
            });
        });
    </script>

</body>
</html>